# -- coding: utf-8 --
# @Time : 2022-3-3 13:47
# @Author : huabao.tan
# @File : creat_excel.py
import random

from power.db.config import *
from power.db.query_mysql import *
from tool.allFunction.Function import *


class CreatPowerExcel(CreatExcel, SqlNameCode):

    def __init__(self):
        super(CreatPowerExcel, self).__init__()
        self.c = SqlNameCode()

    def creat_data(self, rows):
        col = 0
        col2 = 0
        xuhao = 0
        row = 1
        for a in LIST:
            col += 1
            self.sheet_row_col_value(0, 1, col, a)
        for o in LIST2:
            col2 += 1
            self.sheet_row_col_value(1, 1, col2, o)
        while row <= rows:
            row += 1
            cols = 0
            col1 = 0
            xuhao += 1
            name_code = self.c.result()
            name = name_code[1]
            code = name_code[0]
            report_name = str(random.randint(2000, 2022)) + '年度报告'
            creat_repore_time = str(random.randint(2018, 2024)) + '年' + str(random.randint(1, 12)) + '月'
            year = str(random.randint(2018, 2022)) + '年'
            data = ['万花', '七秀', '五毒', '纯阳', '少林', '藏剑', '天策', '丐帮', '唐门', '明教', '苍云', '长歌', '霸刀', '蓬莱', '凌雪阁']
            data = random.choice(data)
            list = [xuhao, name, '', unit(), unit(), xuhao, affiliation_type(), fenshu(), xuhao, unit(), fenshu(),xuhao, unit(), fenshu(), xuhao, unit(), fenshu(), xuhao, fenshu(), xuhao, specialty(), xuhao, fenshu(),
                    xuhao, fenshu(), xuhao, fenshu(), xuhao, unit(), position(), affiliation_type(), fenshu(), of_type(),position(), position(), native_place(), specialty(), code, nation(), report_name, creat_repore_time]
            list2 = [name, year, data, xuhao, fenshu(), baifenbi(), data, year + data + str(fenshu()), nation(), code]
            for b in list:
                cols += 1
                self.sheet_row_col_value(0, row, cols, b)
            for i in list2:
                col1 += 1
                self.sheet_row_col_value(1, row, col1, i)
        self.save_file()


if __name__ == '__main__':
    c = CreatPowerExcel()
    c.creat_data(964)
